package com.example.Service.Impl;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.Service.UserService;
import com.example.mapper.SysRoleRightMapper;
import com.example.mapper.UserMapper;
import com.example.pojo.SysRole;
import com.example.pojo.SysRoleRight;
import com.example.pojo.SysUser;
import com.example.pojo.Vo.SysUserVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, SysUser> implements UserService {

    @Autowired
    UserMapper userMapper;

    @Resource
    SysRoleRightMapper sysRoleRightMapper;

    @Override
    public SysUserVo getLogin(String usrName, String usrPassword) {
        return userMapper.getLogin(usrName,usrPassword);
    }

    @Override
    public SysUserVo findUserByUsrName(String usrName) {
        return userMapper.findUserByUsrName(usrName);
    }

    @Override
    public List<SysRoleRight> getRoleRightListById(Long roleId) {
        QueryWrapper<SysRoleRight> queryWrapper = new QueryWrapper();
        queryWrapper.lambda().eq(roleId!=0,SysRoleRight::getRfRoleId,roleId);
        return sysRoleRightMapper.selectList(queryWrapper);
    }

    @Override
    public IPage<SysUserVo> getPage(Page page, SysUserVo sysUserVo) {
        return userMapper.getPage(page,sysUserVo);
    }
}
